-
Notifications
You must be signed in to change notification settings - Fork 277
Replace use of deprecated nil_typet in java_type_from_string [blocks: #3800] #3929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
af40105
to
e4cffb5
Compare
e4cffb5
to
4e6d256
Compare
4e6d256
to
4aad8d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫
This PR failed Diffblue compatibility checks (cbmc commit: 4aad8d1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/98657901
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
4aad8d1
to
152dfcc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫
This PR failed Diffblue compatibility checks (cbmc commit: 152dfcc).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/98710526
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
// NOLINTNEXTLINE(whitespace/braces) | ||
symbol_exprt generic_param{ | ||
"specalisedGeneric", | ||
java_type_from_string("LDummyGeneric<Ljava/lang/Interger;>;")}; | ||
*java_type_from_string("LDummyGeneric<Ljava/lang/Interger;>;")}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Is Interger
intended here (and below)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess not...! Will have a detailed look at this test, but of course no more or less broken than it was before.
@@ -582,26 +582,25 @@ typet java_type_from_string( | |||
std::back_inserter(parameters), | |||
[](const typet &type) { return java_method_typet::parametert(type); }); | |||
|
|||
return java_method_typet(std::move(parameters), std::move(return_type)); | |||
return java_method_typet(std::move(parameters), std::move(*return_type)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure this has a value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea, but it was previously used without any sanity check, so I'd now rely on operator*
failing an assertion...
f.descriptor, | ||
f.signature, | ||
id2string(class_symbol.name)); | ||
field_type = *java_type_from_string_with_exception( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure this has a value? (and other places)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above: no idea, but it was previously used unchecked. There are a couple of places that failed this while running the regression tests, and those I have now guarded appropriately. I still think that this makes optionalt<typet>
much better as at least you'd have a failing assertion instead of silently passing around a nil_typet
that some later stage won't know how to deal with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will create a manual bump for this.
std::ostringstream id_oss; | ||
id_oss << method_id << "::" << v.name; | ||
irep_idt identifier(id_oss.str()); | ||
symbol_exprt result(identifier, t); | ||
symbol_exprt result = symbol_exprt::typeless(identifier); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ This change looks a little suspicious? Previously the type of the symbol was derived from the signature or descriptor, now is a typeless identifier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type was sometimes nil_typet()
(because trying to derive the type failed) and nobody noticed, because really the type of this is never used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case could I suggest using an irep_idt
instead of a symbol_exprt
? Otherwise someone will surely assume that variables[n].type()
is a sensible thing to look at.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would necessitate some refactoring of this code as the expression is also used to communicate ID_C_base_name
.
@@ -548,8 +548,8 @@ void java_bytecode_parsert::get_class_refs() | |||
|
|||
case CONSTANT_NameAndType: | |||
{ | |||
typet t=java_type_from_string(id2string(pool_entry(c.ref2).s)); | |||
get_class_refs_rec(t); | |||
const auto t = java_type_from_string(id2string(pool_entry(c.ref2).s)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ while in the area, t
-> type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just got rid of it, it didn't carry much value...
else | ||
method_type=java_type_from_string(method.descriptor); | ||
else if(const auto method_type = java_type_from_string(method.descriptor)) | ||
get_class_refs_rec(*method_type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Might be worth sticking a warning here that it somehow failed to get the type from both the signature and the descriptor. I'd even be tempted to put an UNREACHABLE;
here, but I suppose this is one of the cases you were referring to where this broke tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, this is reachable/reached in several regression tests. I don't feel sufficiently competent on this code to assess whether that's actually a problem. Any volunteers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put UNREACHABLE;
here and didn't get any failures in jbmc*
- have a specific example? (will try the other two places too).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what exactly your change was, but I'd just use else { typet method_type = *java_type_from_string(method.descriptor); get_class_refs_rec(method_type); }
here.
var_type=java_type_from_string(var.descriptor); | ||
get_class_refs_rec(var_type); | ||
else if(const auto var_type = java_type_from_string(var.descriptor)) | ||
get_class_refs_rec(*var_type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Again - some kind of warning in the else
case makes sense here I think. 🔥
get_class_refs_rec(value_type); | ||
const auto value_type = java_type_from_string(id2string(value_id)); | ||
if(value_type.has_value()) | ||
get_class_refs_rec(*value_type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 🔥
// NOLINTNEXTLINE(whitespace/braces) | ||
symbol_exprt generic_param{ | ||
"specalisedGeneric", | ||
java_type_from_string("LDummyGeneric<Ljava/lang/Interger;>;")}; | ||
*java_type_from_string("LDummyGeneric<Ljava/lang/Interger;>;")}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess not...! Will have a detailed look at this test, but of course no more or less broken than it was before.
152dfcc
to
c523d5f
Compare
I will have a look and see whether this looks like a real concern or not. |
INVARIANT(member_type_from_signature.id()==ID_code, "Must be code type"); | ||
auto member_type_from_signature = | ||
java_type_from_string(signature.value(), class_name); | ||
INVARIANT( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd actually delete this, we're about to check both those things by deref'ing and casting
std::ostringstream id_oss; | ||
id_oss << method_id << "::" << v.name; | ||
irep_idt identifier(id_oss.str()); | ||
symbol_exprt result(identifier, t); | ||
symbol_exprt result = symbol_exprt::typeless(identifier); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case could I suggest using an irep_idt
instead of a symbol_exprt
? Otherwise someone will surely assume that variables[n].type()
is a sensible thing to look at.
@tautschnig it's unsurprising with our known-to-be-broken generic signature parsing sometimes bails with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks TG (both a trivial compile error and a failing test) I'm investigating now.
Now waiting on CI - in the mean time will investigate the above optional returns. |
Thank you @thk123 ! |
@tautschnig I've made tautschnig#12 which tightens these to not allow the descriptor to fail (I could only find one failing test - and the problem was the test). Happy for you to fold that into this PR or get this one merged and then I'll raise that as a new PR. (TG bump is based at this PR and is still running, but passed some tests locally). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫
This PR failed Diffblue compatibility checks (cbmc commit: c523d5f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/99277071
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
d1bcbec
to
adf6c12
Compare
@thk123 PR merged in here and the entire branch rebased onto latest develop, you might want to update the TG bump to use this? |
Use optionalt<typet> as recommended in the deprecation note.
The jasmin contained two errors: calling base class constructor with invokevirtual rather than invokespecial the descriptor of the type for the local variable was not a valid descriptor.
There should be no unsupported cases here.
adf6c12
to
8f71a23
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫
This PR failed Diffblue compatibility checks (cbmc commit: 8f71a23).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/99300653
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
TG bump passing. |
Use typet or optionalt.
Do not review just yet, I will split this up in several commit as it touches way too many parts of the codebase in a single commit.